<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>案件收支录入</title>
    <link rel="stylesheet" href="../../layuiadmin/js/finance/js/bootstrap/css/bootstrap.min.css" />
    <script type="text/javascript" src="../../layuiadmin/js/finance/js/jquery.min.js" ></script>
    <script type="text/javascript" src="../../layuiadmin/js/finance/js/bootstrap/js/bootstrap.js" ></script>
    <script>
        $(document).ready(function () {
            var a = localStorage.getItem("gathering");
            var lql = eval("("+a+")");
            var money=lql.amountMoney;
            $.post("http://localhost:8080/financePayoutController/payouttypelist",function(msg){
                for(var i=0;i<msg.length;i++){
                    var payoutType=$("#payoutType");
                    if(msg[i].pid==0){
                        var op=$("<option value='"+msg[i].payoutTypeId+"' disabled='false'>"+msg[i].payoutName+"</option>");
                    }else if(msg[i].pid!=100103){
                        var op = $("<option value='"+msg[i].payoutTypeId+"'>"+"&nbsp&nbsp----" + msg[i].payoutName + "</option>");
                    }else{
                        var op = $("<option value='"+msg[i].payoutTypeId+"'>"+"&nbsp&nbsp&nbsp&nbsp----" + msg[i].payoutName + "</option>");
                    }
                    payoutType.append(op);
                }
            });
            $.post("http://localhost:8080/financePayoutController/paytype",function(msg) {
                for(var i=0;i<msg.length;i++){
                    var paytype=$("#paytype");
                    var op=$("<option value='"+msg[i].payId+"'>"+msg[i].payType+"</option>");
                    paytype.append(op);
                }
            });
            $.post("http://localhost:8080/financeIncomeController/caselist",{"caseid":lql.caseId},function (msg) {
                var myDate = new Date();
                var year=myDate.getFullYear();
                var month=myDate.getMonth()+1;
                var date=myDate.getDate();
                var now=year+'-'+month+"-"+date;
                var caseid=$("#caseid").text(lql.caseId);
                var incomedate=$("#incomedate").text(now);
                var incomemoney=$("#incomemoney").text(msg.amountMoney);
                var agencyMoney=$("#agencyMoney").text(msg.agencyMoney);
                var yipay=$("#yipay").text(msg.realityMoney);
                var yiopeninvoice=$("#yiopeninvoice").text(msg.invoiceMoney);
            });
        });
        function getlist() {
            var url = location.search; //获取url中"?"符后的字串
            var theRequest = new Object();
            if (url.indexOf("?") != -1) {
                var str = url.substr(1);
                var strs = str.split("&"); //将所有参数拆分放入数组
                for (var i = 0; i < strs.length; i++) {  //遍历参数数组
                    theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }
        function add() {
            var caseid=$("#caseid").text();
            var incomedate=$("#incomedate").text();
            var incomemoney=$("#incomemoney").text();
            var agencyMoney=$("#agencyMoney").text();
            var yipay=$("#yipay").text();
            var yiopeninvoice=$("#yiopeninvoice").text();
            var payer=$("#payer").val();
            var payoutType=$("#payoutType").val();
            var paytype=$("#paytype").val();
            var remark=$("#remark").val();
            $.post("http://localhost:8080/financeIncomeController/caselist",{"caseid":caseid},function (msg) {
                $.post("http://localhost:8080/financePayoutController/addpayout",
                    {
                        "caseId": caseid,
                        "enteringDate": incomedate,
                        "inoutMoney": incomemoney,
                        "inoutPerson":msg.mainLawyer.empId,
                        "payoutTypeId":payoutType,
                        "payId":paytype,
                        "payer":payer,
                        "remark":remark,
                        "paytype":paytype
                    },
                    function () {
                        alert("提交成功");
                        window.location.href = "../../views/case/Case_init.html?";
                    });
            });
        }
    </script>
</head>
<body>
<div class="container-fluid">
    <form class="form-horizontal form-inline">
        <div id="div2">
            <div class="row">
                <div class="col-lg-12">
                    <div class="col-lg-1"></div>
                    <div class="col-lg-11">
                        <font style="font-size: 20px"><strong>|案件收支</strong></font><br>
                    </div>
                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-5">
                        <label><font style="color: red">*</font>案号：</label>
                        <span id="caseid"></span>
                    </div>
                    <div class="col-lg-6">
                        <label><font style="color: red">*</font>应付金额：</label>
                        <span id="incomemoney"></span>
                    </div>
                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-5">
                        <label><font style="color: red">*</font>收支日期：</label>
                        <span id="incomedate" readonly="readonly"></span>
                    </div>
                    <div class="col-lg-6">
                        <label for="yipay"><font style="color: red">*</font>实付款：</label>
                        <span id="yipay"></span>
                    </div>
                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-5">
                        <label for="agencyMoney"><font style="color: red">*</font>代理费：</label>
                        <span id="agencyMoney"></span>
                    </div>
                    <div class="col-lg-6">
                        <label for="yiopeninvoice"><font style="color: red">*</font>开票金额：</label>
                        <span id="yiopeninvoice"></span>
                    </div>

                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-5">
                        <label for="yipay"><font style="color: red">*</font>付款人：</label>
                        <input type="text" id="payer" class="form-control">
                    </div>
                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-5">
                        <label for="payoutType"><font style="color: red">*</font>收支类别：</label>
                        <select id="payoutType" class="form-control">
                            <option value="-1">请选择</option>
                        </select>
                    </div>
                    <div class="col-lg-6">
                        <label for="paytype"><font style="color: red">*</font>支付方式：</label>
                        <select id="paytype" class="form-control">
                            <option value="-1">请选择</option>
                        </select>
                    </div>
                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-11">
                        <label for="remark"><font style="color: red">*</font>备注：</label>
                        <textarea class="form-control" style="width:100%" id="remark"></textarea>
                    </div>
                </div>
                <div class="col-lg-12">
                    <br>
                    <div class="col-lg-1"></div>
                    <div class="col-lg-11">
                        <button type="button" class="btn btn-success" onclick="add()">确认提交</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
</body>
</html>